package com.qianyu.controller.back;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qianyu.anno.OperLogAnnotation;
import com.qianyu.entity.base.BaseIdDto;
import com.qianyu.entity.base.Result;
import com.qianyu.entity.bean.QqAccount;
import com.qianyu.entity.dto.QqAccountDto;
import com.qianyu.enumerate.OperLogEnum;
import com.qianyu.service.QqAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "后台账号管理", description = "wangzhicheng")
@RestController
@RequestMapping("/back/qq_account")
@RequiredArgsConstructor
public class QqAccountController {
    private final QqAccountService qqAccountService;

    /**
     * 新增qq账号
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增qq账号")
    @OperLogAnnotation(menuName = "账号管理",opeType = OperLogEnum.INSERT)
    Result<String> saveQqAccount(@RequestBody @Validated QqAccountDto.QqAccountSaveDto dto) {
        return qqAccountService.saveQqAccount(dto) ? Result.success() : Result.error();
    }

    /**
     * 分页筛选账号
     *
     * @param dto
     * @return
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "分页筛选账号")
    Result<Page<QqAccount>> pageList(@RequestBody @Validated QqAccountDto.QqAccountPageDto dto) {
        return Result.success(qqAccountService.pageList(dto));
    }

    /**
     * 查询账号详情
     *
     * @param dto
     * @return
     */
    @PostMapping("/getInfo")
    @ApiOperation(value = "查询账号详情")
    Result<QqAccount> getInfo(@RequestBody @Validated BaseIdDto dto) {
        return Result.success(qqAccountService.getInfo(dto));
    }
}
